﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using ArchitectingInnovation.PRISMvvM.Core.Modularity;
using Microsoft.Practices.Prism.Modularity;
using Microsoft.Practices.Prism.UnityExtensions;

namespace ArchitectingInnovation.PRISMvvM.Core.BootstrapperExtensions
{
    public abstract class DefaultBootstrapper : UnityBootstrapper
    {

        protected override Microsoft.Practices.Prism.Modularity.IModuleCatalog CreateModuleCatalog()
        {

            var catalog = base.CreateModuleCatalog();
            var downloader = new ManifestDownloader();
            downloader.Download();
            while(!downloader.Done)
            {}
            if (downloader.Manifest != null)
            {
                foreach (var module in downloader.Manifest.Modules)
                {
                    catalog.AddModule(module);
                }
            }
            return catalog;
        }
    }
}
